import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

// 配置菜单图标
import menusIcon from './menusIcon.json'
export default new Vuex.Store({
  state: {
    menusIcon:menusIcon,
    token: localStorage.getItem('cms-token'),
    username: localStorage.getItem('username'),
    opened: true
  },
  mutations: {
    setToken(state, payload) {
      state.token = payload

      localStorage.setItem('cms-token', payload);
    },
    removeToken(state) {
      state.token = null
      localStorage.removeItem('cms-token')
    },
    setUsername(state, payload) {
      state.username = payload
      localStorage.setItem('username', payload)
    },
    setSideBarOpen(state) {
      state.opened = !state.opened
    },
    removeUsername(state) {
      state.username = null
      localStorage.removeItem('username')
    },
  },

  actions: {
  },
  modules: {
  }
})
